﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
//
using BLL;
using Model;

namespace T03.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/
        ArticlesBLL bll = new ArticlesBLL();
        // GET: /Home/Index
        public ActionResult Index()
        {
            //默认为最新,按发帖时间倒序排序
            ViewBag.list = bll.GetAll().OrderByDescending(o => o.CreateTime);
            return View();
        }

        // GET: /Home/Jinghua
        public ActionResult Jinghua()
        {
            //精华,按点赞人次倒序查询帖子
            ViewBag.list = bll.GetAll().OrderByDescending(o => o.Zan);
            return View();
        }

        // GET: /Home/Remen
        public ActionResult Remen()
        {
            //热门,按浏览人次倒序查询帖子
            ViewBag.list = bll.GetAll().OrderByDescending(o => o.Dian);
            return View();
        }

        // GET: /Home/Index 查询
        [HttpPost]
        public ActionResult Index(string searchtxt)
        {
            ViewBag.stxt = searchtxt;//保存查询条件
            ViewBag.list = bll.GetAllByTiao(searchtxt);//查询结果
            return View();
        }

        // GET: /Home/Error //显示通过错误信息提示
        public ActionResult Error()
        {
            return View();
        }
    }
}
